using System.Windows.Controls;
using System.Windows.Documents;

namespace YouVisio.Silverlight.TextDiff
{
    public class TextDiffOutputBox : RichTextBox
    {
        private ScrollViewer _scrollViewer;
        public ScrollViewer ScrollViewer
        {
            get
            {
                if (this._scrollViewer == null)
                {
                    this._scrollViewer = GetTemplateChild("ContentElement") as ScrollViewer;
                }
                return this._scrollViewer;
            }
        }

        public double LineHeight
        {
            get
            {
                if (this.Blocks.Count == 0) return 0;
                var paragraph = this.Blocks[0] as Paragraph;
                if (paragraph == null || paragraph.Inlines.Count == 0) return 0;
                return paragraph.Inlines[0].ContentStart.GetCharacterRect(LogicalDirection.Forward).Height;
            }
        }
    }
}